package com.trs.progress.button.sample;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;

import com.trs.progress.button.ProgressButton;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {

    ProgressButton progressButton;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        init();
    }

    void init() {
        progressButton = (ProgressButton) findViewById(R.id.pbtn);
        progressButton.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        int id = v.getId();
        switch (id) {
            case R.id.pbtn:
                clickProgressButton();
                break;
        }
    }

    private void clickProgressButton() {
        if (progressButton.isLoading()) {
            progressButton.stopLoading();
        } else {
            progressButton.startLoading();
        }
    }

}